package huawei;

/**
 * ⚽️字符串中所有的整数的最小和
 */
public class Q118 {

    public static void main(String[] args) {
        String s = "bb12-34aa";

        Long result = 0L;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) >= '0' && s.charAt(i) <= '9' ) {
                Long sum = 0L;
                int t = i;
                while (t < s.length()) {
                    if (s.charAt(t) >= '0' && s.charAt(t) <= '9') {
                        sum += s.charAt(t) - '0';
                    } else {
                        break;
                    }
                    t += 1;
                }
                if (i > 0 && s.charAt(i-1) == '-') {
                    sum = -Long.parseLong(s.substring(i, t));
                }

                result += sum;
                i = t - 1;
            }
        }

        System.out.println(result);
    }
}
